home *** CD-ROM | disk | FTP | other *** search
- /*
- * CBLibrary - Loader
- * Copyright (C) 2003 Chris Bazley
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /*
- The general idea of the Loader component is that it provides a much
- higher-level, structured approach to data-transfer. A client
- application can simply register and deregister an interest (a
- 'listener') for particular drop locations/file types, and a handler to
- be called when data is received.
-
- Two utility functions are provided: loader_buffer_file(), which
- buffers a file in a flex block and loader_canonicalise(), which writes
- back a pointer to a malloc block containing a canonicalised file path.
-
- All applications using this component need the following messages:
- BadListReg, TransUXreq, LoadFail, FileNotPerm, NoSuchFileType,
- NoSuchDropZone, WrongZone
-
- Requires toolboxlib, eventlib and flexlib
- */
-
- #ifndef FlexLoader_h
- #define FlexLoader_h
-
- #include <stdbool.h>
- #include "kernel.h"
- #include "flex.h"
- #include "toolbox.h"
-
- /* ---------------- Client-supplied participation routines ------------------ */
-
- typedef _kernel_oserror *(LoaderFileHandler) (char *file_path,
- flex_ptr buffer);
-
- typedef void (LoaderFinishedHandler) (char *title,
- bool data_saved,
- flex_ptr buffer,
- int filetype,
- void *handle);
- /*
- If 'data_saved' is set then 'title' will be the full CANONICALISED
- path of the file from which the data was loaded. The case of 'title'
- is not defined.
- */
-
- /* --------------------------- Library functions ---------------------------- */
-
- extern _kernel_oserror *loader_initialise(unsigned int flags);
-
- /* Client-supplied flags for loader_initialise() */
- #define LOADER_IGNOREBCASTS 1 /* Ignore all DataOpen messages */
- #define LOADER_QUIET_BADTYPE 2 /* Suppress various errors... */
- #define LOADER_QUIET_BADDROP 4
- #define LOADER_QUIET_NOTPERM 8
-
- extern _kernel_oserror *loader_finalise(void);
-
- extern _kernel_oserror *loader_register_listener(
- unsigned int flags,
- int file_type,
- ObjectId drop_object,
- ComponentId *drop_gadgets,
- LoaderFileHandler *loader_method,
- LoaderFinishedHandler *finished_method,
- void *client_handle);
-
- /* Client-supplied flags for loader_register_listener() */
- #define LISTENER_CLAIM 1 /* Should we also claim double-clicks */
- #define LISTENER_FILEONLY 2 /* Only load permanent files */
- #define LISTENER_SPRITEAREAS 4 /* Load sprite files as sprite areas */
- #define FILETYPE_ALL -1
-
- extern _kernel_oserror *loader_deregister_listener(int file_type,
- ObjectId drop_object,
- ComponentId *drop_gadgets);
-
- /* OS_FSControl 37 with two passes */
- extern _kernel_oserror *loader_canonicalise(char **buffer, const char *path_var, const char *path_string, const char *file_path);
-
- /* 'Cos we're feeling generous */
- extern _kernel_oserror *loader_buffer_file(const char *file_path,
- flex_ptr buffer,
- bool sprite_file);
-
- #endif
-